<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>
        等级管理
    </title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="../../../backstage/css/x-admin.css" media="all">
</head>

<body>
    <div class="x-nav">
        <span class="layui-breadcrumb">
            <a><cite>首页</cite></a>
            <a><cite>会员管理</cite></a>
            <a><cite>优惠券管理</cite></a>
        </span>
        <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
            <i class="layui-icon" style="line-height:30px">ဂ</i>
        </a>
    </div>
    <div class="x-body">
        <div id="block">
            <%--<button class="layui-btn layui-btn-danger" onclick="delAll()">--%>
                <%--<i class="layui-icon">&#xe640;</i>批量删除--%>
            <%--</button>--%>
            <button class="layui-btn" onclick="level_add('添加优惠券','${path}/admin/couponAdd','','800','600')">
                <i class="layui-icon">&#xe608;</i>添加
            </button>
            <%--<span class="x-right" style="line-height:40px">共有数据：88 条</span>--%>
        </div>
        <table class="layui-table">
            <thead>
                <tr>
                    <th>ID</th>
                    <th>优惠券名称</th>
                    <th>上架日期</th>
                    <th>生效对象</th>
                    <th>生效时长</th>
                    <th>更新日期</th>
                    <th>使用方式</th>
                    <th>描述</th>
                    <th>价格</th>
                    <th>积分</th>
                    <th>状态</th>
                    <th>备注</th>
                    <th>
                        操作
                    </th>
                </tr>
            </thead>
            <tbody id="coupon">
                <tr>
                    <%--<td>--%>
                        <%--1--%>
                    <%--</td>--%>
                    <%--<td>--%>
                        <%--LV1--%>
                    <%--</td>--%>
                    <%--<td>--%>
                        <%--8折--%>
                    <%--</td>--%>
                    <%--<td class="td-manage">--%>
                        <%--<a title="编辑" href="javascript:;" onclick="level_edit('编辑','${path}/admin/couponEdit','4','500','500')" style="text-decoration:none">--%>
                            <%--<i class="layui-icon">&#xe642;</i>--%>
                        <%--</a>--%>
                        <%--&lt;%&ndash;<a title="删除" href="javascript:;" onclick="level_del(this,'1')" style="text-decoration:none">&ndash;%&gt;--%>
                            <%--&lt;%&ndash;<i class="layui-icon">&#xe640;</i>&ndash;%&gt;--%>
                        <%--&lt;%&ndash;</a>&ndash;%&gt;--%>
                    <%--</td>--%>
                </tr>
            </tbody>
        </table>
    </div>
    <script src="../../../backstage/js/jquery.min.js"></script>
    <script src="../../../backstage/lib/layui/layui.js" charset="utf-8"></script>
    <script src="../../../backstage/js/x-admin.js"></script>
    <script src="../../../backstage/js/x-layui.js" charset="utf-8"></script>
    <script>
        layui.use(['element', 'layer'], function() {
            $ = layui.jquery; //jquery
            lement = layui.element(); //面包导航
            layer = layui.layer; //弹出层

            $(document).ready(function() {
                $.ajax({
                    type: 'GET',
                    url: '/member/memberManagement/showAllCoupon',
                    dataType: "json",
                    error: function () {
                        console.log("失败");
                    },
                    success: function (data) {
                        console.log(data);

                        if (data) {
                            var str = '';
                            for (i = 0; i < data.length; i++) {
                                var coupon = data[i];

                                str += '<tr>';
                                str += '  <td>' + coupon.id + '</td>';
                                str += '  <td>' + coupon.itemName + '</td>';
                                str += '  <td>' + new Date(coupon.createDate).toLocaleDateString().replace(/\//g, "-") + " " + new Date(coupon.createDate).toTimeString().substr(0, 8) + '</td>';
                                str += '  <td>' + coupon.subject + '</td>';
                                str += '  <td>' + coupon.howLong + '</td>';
                                str += '  <td>' + new Date(coupon.updateDate).toLocaleDateString().replace(/\//g, "-") + " " + new Date(coupon.updateDate).toTimeString().substr(0, 8) + '</td>';
                                str += '  <td>' + coupon.howUse + '</td>';
                                str += '  <td>' + coupon.description + '</td>';
                                str += '  <td>' + coupon.price + '</td>';
                                str += '  <td>' + coupon.credit + '</td>';
                                str += '  <td>' + coupon.state + '</td>';
                                str += '  <td>' + coupon.remark + '</td>';
                                str += '<td class="td-manage"> <a title="编辑" class="ml-5" style="text-decoration:none" href="javascript:void(0)" onclick="level_edit(this)" data-id=' + coupon.id + ' >' + ' <i class="layui-icon">' + "&#xe642;" + '</i> </a> </td>';
                                str += '</tr>';
                            }
                            $('#coupon').html(str);
                        }else{
                            var input = "找到0条记录";
                            $('#coupon').html(input);
                        }
                    }
                });
            });


        });


        // 增加
        function level_add(title, url, id, w, h) {
            x_admin_show(title, url, w, h);
        }
        // 编辑
        function level_edit(coupon) {

            window.localStorage.setItem('msg',$(coupon).data("id"));
            x_admin_show("编辑", "${path}/admin/couponEdit", 810,400);
        }

    </script>
</body>

</html>